package com.service.component.user.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.service.component.common.entity.CommonEntity;
import com.service.component.permissions.entity.Permission;
import com.service.component.role.entity.Role;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.*;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "用户信息表")
@TableName(value = "SYS_USER")
/**
 * @author ：Calvin
 * @date ：Created in 2021/7/16 14:35
 * @description：用户信息表
 * @modified By：
 * @version: 1.0.0$
 */
public class Users extends CommonEntity {

    /**
     * 用户编号
     */
    @TableField(value = "USER_NO")
    @ApiModelProperty(value = "用户编号")
    private String userNo;

    /**
     * 地址
     */
    @TableField("ADDRESS")
    @ApiModelProperty(value = "地址")
    private String address;

    /**
     * 用户名
     */
    @TableField("USERNAME")
    @NotNull(message = "用户名不能为空")
    @ApiModelProperty(value = "用户名")
    private String username;

    /**
     * 密码
     */
    @TableField("PASSWORD")
    @ApiModelProperty(value = "密码")
    @Range(min = 6,max = 16,message = "密码长度不能小于6位，并且不能大于16位")
    private String password;

    /**
     * 昵称
     */
    @TableField("NICKNAME")
    @ApiModelProperty(value = "昵称")
    private String nickname;

    /**
     * 性别
     */
    @TableField("SEX")
    @ApiModelProperty(value = "性别")
    private String sex;

    @TableField("AGE")
    @ApiModelProperty(value = "年龄")
    @DecimalMax(value = "150",message = "年龄必须为数字,并且范围必须处于0-150之间")
    @Range(min = 0,max = 150,message = "根据世界吉尼斯记录统计，年龄范围必须处于0-150之间")
    private String age;

    /**
     * 电子邮箱
     */
    @TableField("E_MAIL")
    @ApiModelProperty(value = "电子邮箱")
    @Email(message = "邮箱格式错误")
    private String eMail;

    /**
     * 电话
     */
    @TableField("PHONE")
    @ApiModelProperty(value = "电话")
    @Pattern(regexp ="^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误")
    @Max(value = 11,message = "手机号只能为{max}位")
    @Min(value = 11,message = "手机号只能为{min}位")
    private String phone;

    /**
     * 头像
     */
    @ApiModelProperty(value = "头像")
    @TableField("HEAD_IMG")
    private String headImg;

    /**
     * 盐
     */
    @ApiModelProperty(value = "盐")
    @TableField("SALT")
    private String salt;

    /**
     * 状态
     */
    @ApiModelProperty(value = "状态")
    @TableField("STATUS")
    private String status;

    /**
     * 删除标识
     */
    @ApiModelProperty(value = "删除标识")
    @TableField("DELFALG")
    private String delFalg;


    @TableField(exist = false)
    @ApiModelProperty(value = "用户角色")
    private List<Permission> permissions;

    @TableField(exist = false)
    @ApiModelProperty(value = "用户权限")
    private List<Role> roles;

}
